package cn.it.controller;

import cn.it.Service.ICarServices;
import cn.it.domain.Car;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CarController {
    @Autowired
    private ICarServices iCarServices;


    @RequestMapping("findCarByid")
    public Car findCarByid(Integer id){
        Car car=iCarServices.SelectOne(id);
        return car;
    }
    @RequestMapping("findCar")
    public List<Car> findCarByid(){

        PageHelper.startPage(2,5);
        Page<Car> car=(Page)iCarServices.SelectAll();
        System.out.println(car);

        for (Car car1 : car){
            System.out.println(car1);
        }
        return car;
    }
}
